const path = require('path')
const { defineConfig } = require('@vue/cli-service')
const proxy = require('./config/proxy')
const resolve = (src) => path.resolve(__dirname, src)
const register = require('./config/backend')
module.exports = defineConfig({
	transpileDependencies: true,
	outputDir: 'pinganWorriesFree',
	css: {
		loaderOptions: {
			sass: {
				// 全局引入变量和 mixin
				additionalData: `
          @import "assets/scss/variable.scss";
          @import "assets/scss/mixin.scss";
        `
			}
		}
	},
	publicPath: '/mobile/pinganWorriesFree',
	devServer: {
		// https: true,
		client: {
			overlay: false
		},
		proxy: {
			'/api': {
				target: proxy,
				changeOrigin: true
			},
			'/renren-fast': {
				target: proxy,
				changeOrigin: true
			},
			'/img/': {
				target: proxy,
				changeOrigin: true
			}
		},
		onBeforeSetupMiddleware(devServer) {
			register(devServer.app)
		}
	},
	chainWebpack: (config) => {
		config.plugin('html').tap((args) => {
			args[0].title = ''
			return args
		})
		config.resolve.alias
			.set('@', resolve('./src'))
			.set('components', resolve('./src/components'))
			.set('composition', resolve('./src/composition'))
			.set('views', resolve('./src/views'))
			.set('assets', resolve('./src/assets'))
			.set('const', resolve('./const'))
			.set('utils', resolve('./src/utils'))
			.set('api', resolve('./src/api'))
		// set第一个参数：设置的别名，第二个参数：设置的路径
	}
})
